package tp.badugi.client.guiViews;

import java.awt.Dimension;
import java.awt.GridLayout;

import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.SwingConstants;

public class GameViewPlayerInfoTable extends JPanel{

	/**
	 * 
	 */
	private static final long serialVersionUID = -7394377500751143125L;

	public JPanel[] columnPanel;
	
	public JLabel[] columnNameLabels;
	
	public JLabel[][] dataLabels;
	
	private GridLayout layout;
	
	private Dimension labelPrefferedSize = new Dimension(150,10);
	
	public GameViewPlayerInfoTable(String[] columnNames, int columns, int rows) {
		
		this.columnPanel = new JPanel[columns];
		this.columnNameLabels = new JLabel[columns];
		this.dataLabels = new JLabel[columns][rows];
		
		this.setPreferredSize(new Dimension(600,50));
		
		this.layout = new GridLayout(rows+1,1);
		
		this.setLayout(new GridLayout(1,columns));
		
		for(int i = 0; i < columns; i++){
			
			this.columnPanel[i] = new JPanel();
			this.columnPanel[i].setLayout(this.layout);
			
			this.columnNameLabels[i] = new JLabel();
			
			this.columnNameLabels[i].setText(columnNames[i]);
			this.columnNameLabels[i].setHorizontalAlignment(SwingConstants.CENTER);
			this.columnNameLabels[i].setPreferredSize(this.labelPrefferedSize);
			
			this.columnPanel[i].add(this.columnNameLabels[i]);
			
			for(int j = 0; j < rows; j++){
				
				this.dataLabels[i][j] = new JLabel();
				this.dataLabels[i][j].setHorizontalAlignment(SwingConstants.CENTER);
				this.dataLabels[i][j].setPreferredSize(this.labelPrefferedSize);
				 
				this.columnPanel[i].add(this.dataLabels[i][j]);
				
			}
			
			this.add(this.columnPanel[i]);
			
		}
	}
}
